CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(gobang)

SET(CMAKE_CXX_FLAGS " -Wall ")

INCLUDE_DIRECTORIES(
    ${CMAKE_CURRENT_SOURCE_DIR}/src
    ${CMAKE_CURRENT_SOURCE_DIR}/src/chess
)

# chess代码库
AUX_SOURCE_DIRECTORY(src/chess CHESS_LIST)
ADD_LIBRARY(chess ${CHESS_LIST})

# 小小的命令行测试程序
AUX_SOURCE_DIRECTORY(src/test TEST_LIST)
ADD_EXECUTABLE(test ${TEST_LIST})
TARGET_LINK_LIBRARIES(test chess)

FIND_PACKAGE(Qt4)
# QT-GUI的程序
IF (QT4_FOUND)
    MESSAGE(STATUS "Qt4 found! Will build a Qt4-GUI program.")
    INCLUDE_DIRECTORIES(${QT_INCLUDES})
    QT4_WRAP_CPP(MOC_CODE src/qt/gamewindow.h src/qt/gameboard.h)
    QT4_ADD_RESOURCES(RCC_CODE src/qt/resources.qrc)
    AUX_SOURCE_DIRECTORY(src/qt QT_LIST)
    SET(QT_CODE ${QT_LIST} ${RCC_CODE} ${MOC_CODE})
    ADD_EXECUTABLE(game-qt ${QT_CODE})
    TARGET_LINK_LIBRARIES(game-qt chess ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
ENDIF(QT4_FOUND)

